//
//  ERRootVC.m
//  EnjoyRunning
//
//  Created by ljm on 2017/3/15.
//  Copyright © 2017年 ljm. All rights reserved.
//

#import "ERRootVC.h"

#import "ERLoginVC.h"
#import "ERLaunchVC.h"
#import "ERTHTVC.h"

@interface ERRootVC ()

@end

@implementation ERRootVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    
    [self setControllers];
    
    [self registNotifications];
    
}

#pragma mark -- 加载视图的方法
-(void) setControllers
{
    /*
     *    这里的第一个必须是tabbarvc，否则launch和login界面都不会加载
     */
    [self showTabbarVC];
    
    /*
     *    后面的可以调换
     */
//    [self showLoginVC];
    [self showLaunchVC];
}

#pragma mark -- 显示标签控制器
- (void)showTabbarVC
{
    //初始化标签控制器
    ERTHTVC *tvc = [[ERTHTVC alloc] init];
    [self addChildViewController:tvc];
    [self.view addSubview:tvc.view];
    
    self.TBVC = tvc;
}

#pragma mark -- 显示加载界面
- (void) showLaunchVC
{
    //初始化加载界面
    ERLaunchVC *vc = [[ERLaunchVC alloc] init];
    [self addChildViewController:vc];
    [self.view addSubview:vc.view];
}

//#pragma mark --   显示登录界面
//-(void) showLoginVC
//{
//    //初始化登录界面
//    ERLoginVC *vc = [[ERLoginVC alloc] init];
//    [self addChildViewController:vc];
//    [self.view addSubview:vc.view];
//}

#pragma mark -- 注册通知
- (void) registNotifications
{
    /*
     *    给加载界面注册通知
     */
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(showLaunchVC) name:@"showLaunchVC" object:nil];
    
    /*
     *    给登录界面注册通知
     */
//    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLoginVC) name:@"showLoginVC" object:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
